
-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, and Azure
-- --------------------------------------------------
-- Date Created: 11/20/2012 13:02:47
-- Generated from EDMX file: C:\projects\xpress\ongaz\VisualWebGuiApplication2\VisualWebGuiApplication2\OnGaz.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO
USE [Gazon];
GO
IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------


-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[Accompanying_stocks]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Accompanying_stocks];
GO
IF OBJECT_ID(N'[dbo].[Configdb]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Configdb];
GO
IF OBJECT_ID(N'[dbo].[FixOperations]', 'U') IS NOT NULL
    DROP TABLE [dbo].[FixOperations];
GO
IF OBJECT_ID(N'[dbo].[invoiceitems]', 'U') IS NOT NULL
    DROP TABLE [dbo].[invoiceitems];
GO
IF OBJECT_ID(N'[dbo].[Invoices]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Invoices];
GO
IF OBJECT_ID(N'[dbo].[SignPerson]', 'U') IS NOT NULL
    DROP TABLE [dbo].[SignPerson];
GO
IF OBJECT_ID(N'[dbo].[Tank_Stocks]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Tank_Stocks];
GO
IF OBJECT_ID(N'[dbo].[TankFixOperation]', 'U') IS NOT NULL
    DROP TABLE [dbo].[TankFixOperation];
GO
IF OBJECT_ID(N'[dbo].[TransportCompanies]', 'U') IS NOT NULL
    DROP TABLE [dbo].[TransportCompanies];
GO
IF OBJECT_ID(N'[dbo].[UploadedFilesOftanks]', 'U') IS NOT NULL
    DROP TABLE [dbo].[UploadedFilesOftanks];
GO
IF OBJECT_ID(N'[dbo].[users]', 'U') IS NOT NULL
    DROP TABLE [dbo].[users];
GO

-- --------------------------------------------------
-- Creating all tables
-- --------------------------------------------------

-- Creating table 'Accompanying_stocks'
CREATE TABLE [dbo].[Accompanying_stocks] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Title] nvarchar(255)  NOT NULL,
    [Count] nvarchar(255)  NOT NULL,
    [makat] nvarchar(50)  NULL
);
GO

-- Creating table 'TransportCompanies'
CREATE TABLE [dbo].[TransportCompanies] (
    [id] int IDENTITY(1,1) NOT NULL,
    [TransportCompanyName] nvarchar(50)  NULL,
    [TransporterName] nvarchar(50)  NULL,
    [CarNumber] nvarchar(50)  NULL
);
GO

-- Creating table 'FixOperations'
CREATE TABLE [dbo].[FixOperations] (
    [id] int IDENTITY(1,1) NOT NULL,
    [Subject] nvarchar(150)  NULL,
    [oreder] int  NULL
);
GO

-- Creating table 'TankFixOperations'
CREATE TABLE [dbo].[TankFixOperations] (
    [id] int IDENTITY(1,1) NOT NULL,
    [tankID] int  NULL,
    [FixoperationID] int  NULL,
    [date] datetime  NULL,
    [amount] int  NULL,
    [note] nvarchar(500)  NULL,
    [title] nvarchar(250)  NULL
);
GO

-- Creating table 'SignPersons'
CREATE TABLE [dbo].[SignPersons] (
    [id] int IDENTITY(1,1) NOT NULL,
    [PersonName] nvarchar(50)  NULL,
    [PersonSignituare] nvarchar(50)  NULL
);
GO

-- Creating table 'invoiceitems'
CREATE TABLE [dbo].[invoiceitems] (
    [id] int IDENTITY(1,1) NOT NULL,
    [title] nvarchar(50)  NULL,
    [num] nvarchar(50)  NULL,
    [amount] int  NULL,
    [note] nvarchar(250)  NULL,
    [type] nvarchar(50)  NULL,
    [typeid] nvarchar(50)  NULL,
    [invoiceid] nvarchar(50)  NULL
);
GO

-- Creating table 'Configdbs'
CREATE TABLE [dbo].[Configdbs] (
    [id] int IDENTITY(1,1) NOT NULL,
    [invoicelastid] nvarchar(50)  NULL,
    [tankfixlastid] nvarchar(50)  NULL,
    [tankfixformnum] nvarchar(50)  NULL,
    [tanknumber] nvarchar(50)  NULL
);
GO

-- Creating table 'users'
CREATE TABLE [dbo].[users] (
    [id] int IDENTITY(1,1) NOT NULL,
    [firstname] nvarchar(50)  NULL,
    [lastname] nvarchar(50)  NULL,
    [username] nvarchar(50)  NULL,
    [isadmin] bit  NULL,
    [password] nvarchar(50)  NULL
);
GO

-- Creating table 'UploadedFilesOftanks'
CREATE TABLE [dbo].[UploadedFilesOftanks] (
    [id] int IDENTITY(1,1) NOT NULL,
    [filename] nvarchar(50)  NULL,
    [filepath] nvarchar(250)  NULL,
    [tankfixid] nvarchar(50)  NULL
);
GO

-- Creating table 'Invoices'
CREATE TABLE [dbo].[Invoices] (
    [id] int IDENTITY(1,1) NOT NULL,
    [invoiceNumber] nvarchar(50)  NULL,
    [C_to] nvarchar(50)  NULL,
    [date] datetime  NULL,
    [carnum] nvarchar(50)  NULL,
    [address] nvarchar(250)  NULL,
    [transporter] nvarchar(50)  NULL,
    [invoiceItems] int  NULL,
    [havetank] bit  NULL
);
GO

-- Creating table 'Tank_Stocks'
CREATE TABLE [dbo].[Tank_Stocks] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [TankNumber] nvarchar(255)  NULL,
    [TankSystemStatus] nvarchar(255)  NULL,
    [type] nvarchar(255)  NULL,
    [Datetime] datetime  NULL,
    [GazCompanyName] nvarchar(255)  NULL,
    [GazCompanyAddress] nvarchar(255)  NULL,
    [GazDistributor] nvarchar(255)  NULL,
    [Year_of_manufacture] int  NULL,
    [Date_of_Fix] datetime  NULL,
    [manufacture_name] nvarchar(255)  NULL,
    [Tank_Size] nvarchar(50)  NULL,
    [Label_Number] int  NULL,
    [Address_Tank_From] nvarchar(255)  NULL,
    [NumberOfZoklokPort] int  NULL,
    [tankStatus] nvarchar(255)  NULL,
    [TankWithBase_baton] bit  NULL,
    [PersonRecipetsignName] nvarchar(50)  NULL,
    [TransportCompanyName] nvarchar(50)  NULL,
    [orderName] nvarchar(250)  NULL,
    [CarNumber] nvarchar(50)  NULL,
    [PersonRecipetsignSigniture] nvarchar(50)  NULL,
    [TransportCompanyTransportername] nvarchar(50)  NULL,
    [invoiceid] nvarchar(50)  NULL
);
GO

-- --------------------------------------------------
-- Creating all PRIMARY KEY constraints
-- --------------------------------------------------

-- Creating primary key on [Id] in table 'Accompanying_stocks'
ALTER TABLE [dbo].[Accompanying_stocks]
ADD CONSTRAINT [PK_Accompanying_stocks]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [id] in table 'TransportCompanies'
ALTER TABLE [dbo].[TransportCompanies]
ADD CONSTRAINT [PK_TransportCompanies]
    PRIMARY KEY CLUSTERED ([id] ASC);
GO

-- Creating primary key on [id] in table 'FixOperations'
ALTER TABLE [dbo].[FixOperations]
ADD CONSTRAINT [PK_FixOperations]
    PRIMARY KEY CLUSTERED ([id] ASC);
GO

-- Creating primary key on [id] in table 'TankFixOperations'
ALTER TABLE [dbo].[TankFixOperations]
ADD CONSTRAINT [PK_TankFixOperations]
    PRIMARY KEY CLUSTERED ([id] ASC);
GO

-- Creating primary key on [id] in table 'SignPersons'
ALTER TABLE [dbo].[SignPersons]
ADD CONSTRAINT [PK_SignPersons]
    PRIMARY KEY CLUSTERED ([id] ASC);
GO

-- Creating primary key on [id] in table 'invoiceitems'
ALTER TABLE [dbo].[invoiceitems]
ADD CONSTRAINT [PK_invoiceitems]
    PRIMARY KEY CLUSTERED ([id] ASC);
GO

-- Creating primary key on [id] in table 'Configdbs'
ALTER TABLE [dbo].[Configdbs]
ADD CONSTRAINT [PK_Configdbs]
    PRIMARY KEY CLUSTERED ([id] ASC);
GO

-- Creating primary key on [id] in table 'users'
ALTER TABLE [dbo].[users]
ADD CONSTRAINT [PK_users]
    PRIMARY KEY CLUSTERED ([id] ASC);
GO

-- Creating primary key on [id] in table 'UploadedFilesOftanks'
ALTER TABLE [dbo].[UploadedFilesOftanks]
ADD CONSTRAINT [PK_UploadedFilesOftanks]
    PRIMARY KEY CLUSTERED ([id] ASC);
GO

-- Creating primary key on [id] in table 'Invoices'
ALTER TABLE [dbo].[Invoices]
ADD CONSTRAINT [PK_Invoices]
    PRIMARY KEY CLUSTERED ([id] ASC);
GO

-- Creating primary key on [Id] in table 'Tank_Stocks'
ALTER TABLE [dbo].[Tank_Stocks]
ADD CONSTRAINT [PK_Tank_Stocks]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- --------------------------------------------------
-- Creating all FOREIGN KEY constraints
-- --------------------------------------------------

-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------